import request from '@/utils/request'
import axios from 'axios'
const requestOther = axios.create({
  baseURL: 'http://49.232.7.140:45001/valveControl',
  timeout: 5000,
})
// 查询列表
export function getList (data) {
  return request({
    url: '/device/getPage',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 修改设备
export function editDevice (data) {
  return request({
    url: '/device/updateDevice',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}


// 控制设备
export function controlDevice (data) {
  return requestOther({
    // url: '/device/issuance',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}
// 修改设备
// export function updateDevice (data) {
//   return request({
//     url: '/device/update',
//     method: 'post',
//     data: data,
//     headers: {
//       'Content-Type': 'application/json',
//       'Authorization': window.localStorage.getItem('token'),
//     }
//   })
// }

// 获取设备规则
export function getRules (data) {
  return request({
    url: '/rules/getListByID',
    method: 'get',
    params: data,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 生成设备指令
export function getInstruct (data) {
  return request({
    url: '/device/generation',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 下发设备指令
export function comfirmInstruct (data) {
  return request({
    url: '/device/issued',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 设备详情
export function deviceDetail (data) {
  return request({
    url: '/device/getDetail',
    method: 'get',
    params: data,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 设备数据
export function getDeviceData(data) {
  return request({
    url: '/deviceLog/getPage',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 测试设备
export function testDevice(data) {
  return request({
    url: '/device/mock',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 删除设备
// export function deleteDevice (data) {
//   return request({
//     url: '/device/del',
//     method: 'post',
//     data: data,
//     headers: {
//       'Content-Type': 'application/json',
//       'Authorization': window.localStorage.getItem('token'),
//     }
//   })
// }

// 设备属性
// export function deviceProperty(data) {
//   return request({
//     url: '/subscription/getPropertyList',
//     method: 'post',
//     data: data,
//     headers: {
//       'Content-Type': 'application/json',
//       'Authorization': window.localStorage.getItem('token'),
//     }
//   })
// }

// 设备服务
// export function deviceServe(data) {
//   return request({
//     url: '/subscription/getServiceList',
//     method: 'post',
//     data: data,
//     headers: {
//       'Content-Type': 'application/json',
//       'Authorization': window.localStorage.getItem('token'),
//     }
//   })
// }